const {
    Controller
} = require('uni-cloud-router')
const db = uniCloud.database();
const collection =db.collection('user-id-files')
const dbCmd = db.command
module.exports = class FilesController extends Controller {
    async remove() {
		const ctx=this.ctx
		const data=this.ctx.data
		let  {ids}=data
		ids= Array.isArray(ids)?ids:[ids];
		let fileList =await collection.where({
			_id:dbCmd.in(ids)
		}).field({fileID:true}).get()
		fileList=fileList.data.map(item=>{
			return item.fileID
		})
		let res = await collection.where({
		   _id: dbCmd.in(ids)
		}).remove()
		const del = await uniCloud.deleteFile({fileList})
        return {fileList,res,del,action:ctx.event.action}
    }
}
